import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    //这里放全局参数

    testLevel:'',
    percent: 100,
    allRanks:[],
    correctRanks:[],
    allQuestions:[],
    selection:[],
    result:0,
    // getTestLevel(level){
    //   this.testLevel = level
    // }
  },
  mutations: {
    //这里是set方法
    setTestLevel(state,val){
      state.testLevel = val
    },
    setPercent(state,val){
      state.percent = val
    },
    setAllRanks(state,val){
      state.allRanks = val
    },
    setCorrectRanks(state,val){
      state.correctRanks = val
    },
    setAllQuestions(state,val){
      state.allQuestions = val
    },
    setSelection(state,val){
      state.selection = val
    },
    setResult(state,val){
      state.result = val
    }
    //使用的时候get方法和set方法分别是：
    // this.$store.commit('setDemoValue', value);
    // this.$store.getters.getDemoValue
  },
  getters: {
    //get方法
    getTestLevel: state => state.testLevel,
    getPercent: state => state.percent,
    getAllRanks: state => state.allRanks,
    getCorrectRanks: state => state.correctRanks,
    getAllQuestions: state => state.allQuestions,
    getSelection: state => state.selection,
    getResult: state => state.result,
  },
  actions: {
  },
  modules: {
  }
})
